package com.stage.communication;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
/**
 * Created by Stage on 2017/3/24.
 */
public class CustomerService {
    public static void main(String[] args) {
        ArrayList<Socket> clients = new ArrayList<>();
        try {
            ServerSocket serverSocket = new ServerSocket(888);
            ServiceInput input = new ServiceInput(clients);
            Thread inputThread = new Thread(input);
            inputThread.start();
            while (true) {
                Socket socket = serverSocket.accept();
                ServiceRead read = new ServiceRead(socket);
                Thread readThread = new Thread(read);
                readThread.start();
                clients.add(socket);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
